package org.codeart.chainrespon.example03;

import org.codeart.chainrespon.pojo.AuthInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 抽象审核链
 */
public abstract class AuthLink {

    protected static final Logger logger = LoggerFactory.getLogger(AuthLink.class);
    
    protected static final SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    
    // 审核人ID
    protected String levelUserId;
    
    // 审核人姓名
    protected String levelUsername;
    
    // 表示持有下一个处理对象的引用
    private AuthLink next;

    public AuthLink(String levelUserId, String levelUsername) {
        this.levelUserId = levelUserId;
        this.levelUsername = levelUsername;
    }
    
    // 获取下一个处理器
    public AuthLink getNext() {
        return next;
    }
    
    // 向责任链中添加处理器
    public AuthLink appendNext(AuthLink next) {
        this.next = next;
        return this;
    }
    
    // 抽象审核方法
    public abstract AuthInfo doAuth(String uid, String orderId, Date authDate);
}
